package pe.gob.foncodes.ssa.bs.common.util;

import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.export.JRPdfExporterParameter;

public class PDFExporter implements JRExporterStrategy {

    public PDFExporter() {
    }

    @Override
    public JRExporter export(SerializedList<JasperPrint> jasperPrintList, HttpServletResponse response) throws IOException {
        JRPdfExporter exporter = new JRPdfExporter();
        exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrintList);
        exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, response.getOutputStream());
        exporter.setParameter(JRPdfExporterParameter.METADATA_TITLE, "Sistema Integrado de Administracin Tributaria Municipal - SIAT");
        exporter.setParameter(JRPdfExporterParameter.METADATA_SUBJECT, "Servicio de Administracin Tributaria de Trujillo - SATT");
        exporter.setParameter(JRPdfExporterParameter.METADATA_AUTHOR, "Servicio de Administracin Tributaria de Trujillo - SATT");
        exporter.setParameter(JRPdfExporterParameter.METADATA_CREATOR, "Sistema Integrado de Administracin Tributaria Municipal - SIAT");
        exporter.setParameter(JRPdfExporterParameter.METADATA_KEYWORDS, "SATT,SAT,Tributaria,Impuesto,Impuestos,Renta,Papeletas,Vehculo,Vehcular,Predio,Fiscalizacin,Descarga");
        exporter.setParameter(JRPdfExporterParameter.IS_CREATING_BATCH_MODE_BOOKMARKS, Boolean.TRUE);
        exporter.setParameter(JRPdfExporterParameter.IS_COMPRESSED, Boolean.TRUE);
        return exporter;
    }

    @Override
    public String getMimeType() {
        return "application/pdf";
    }

    @Override
    public String getFileExtension() {
        return "pdf";
    }

}